<template>
	<!-- 拼团活动订单详情   活动管理页面进入 -->
	<view>
		<view class="all-perfor">
			<view class="all-perfor-title">
				{{act_msg.name}}
			</view>
			<view class="all-perfor-tip">
				{{activity_title}}
				<!-- 新东方山师二教育季，原价2698元198元8节线下体育课，立省2400元 -->
			</view>
			<view class="all-perfor-money">
				<view class="">
					成交额(元)
				</view>
				<view class="">
					¥{{order_detail.total}}
				</view>
			</view>
			<view class="course-statistics">
				<view class="course-statistics-title">
					课程数据统计
				</view>
				<view class="course-statistics-content">
					<view class="course-statistics-details">
						<view class="">{{order_detail.ordtotal}}</view>
						<view class="">订单数(个)</view>
					</view>
					<view class="course-statistics-line"></view>
					<view class="course-statistics-details">
						<view class="">{{order_detail.courseCount}}</view>
						<view class="">报名课程(个)</view>
					</view>
					<view class="course-statistics-line"></view>
					<view class="course-statistics-details">
						<view class="">{{order_detail.sendCourse}}</view>
						<view class="">赠送课程(个)</view>
					</view>
				</view>
			</view>
			<view class="perfor-execl" @click="excelClick">
				一键导出业绩excel
			</view>
		</view>
		<view class="group-state">
			<view class="group-state-title">
				<view class="">
					<view class="group-state-contain">
						<view :class="groupStatusIndex==index?'group-state-active':''" v-for="(item,index) in groupStatus" :key='index' @click="stateClick(index)">
							{{item}}
						</view>
					</view>
				</view>
			</view>
			<!-- 拼团中 -->
			<view class="group-state-content" v-if="groupStatusIndex == 0 && group_msg.on.length!=0" v-for="(item, index) in group_msg.on" :key='index'>
				<view class="group-state-msg">
					<view class="group-state-msg-left">
						<view class="">
							<image :src="item.user_info != null ? item.user_info.avatar : '' " mode=""></image>
							<view class="">
								团长
							</view>
						</view>
						<text>{{item.user_info != null ?  item.user_info.nickname : ''}}</text>
					</view>
					<view class="group-state-msg-right">
						开团时间：<text>{{item.date_added | formatDates}}</text>
					</view>
				</view>
				<view class="group-state-details">
					<view class="group-state-details-top">
						<view class="group-state-title-details">
							拼团情况
						</view>
						<view class="" @click="checkMenber(item,'on')">
							<view class="">
								查看成员
							</view>
							<image :src="imglink + 'home/arrow-right.png'" mode=""></image>
						</view>
					</view>
					<view class="group-state-details-bottom">
						<view class="course-statistics-details">
							<view class="" style="color: #FF391F;">{{item.group_people.count}}<text style="font-size: 28upx;color: #333333;">/{{order_detail.groupTotal}}</text></view>
							<view class="lack">
								差{{order_detail.groupTotal-item.group_people.count}}人
							</view>
							<view class="">本团成员(人)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">{{item.group_people.sumCourse}}</view>
							<view class="">报名课程(个)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">¥{{item.group_people.sumMoney}}</view>
							<view class="">目前成交金额(元)</view>
						</view>
					</view>
				</view>
			</view>
			<view class="group-state-content" v-if="groupStatusIndex == 1" v-for="(item, index) in group_msg.finish" :key="index">
				<view class="group-state-msg">
					<view class="group-state-msg-left">
						<view class="">
							<image :src="item.user_info != null ? item.user_info.avatar : '' " mode=""></image>
							<view class="">
								团长
							</view>
						</view>
						<text>{{item.user_info != null ?  item.user_info.nickname : ''}}</text>
					</view>
					<view class="group-state-msg-right">
						开团时间：<text>{{item.date_added | formatDates}}</text>
					</view>
				</view>
				<view class="group-state-details">
					<view class="group-state-details-top">
						<view class="group-state-title-details">
							拼团情况
						</view>
						<view class="" @click="checkMenber(item,'finish')">
							<view class="">
								查看成员
							</view>
							<image :src="imglink + 'home/arrow-right.png'" mode=""></image>
						</view>
					</view>
					<view class="group-state-details-bottom">
						<view class="course-statistics-details">
							<view class="" style="color: #FF391F;">{{item.group_people.count}}<text style="font-size: 28upx;color: #333333;">/{{order_detail.groupTotal}}</text></view>
							<view class="lack" style="width: 122upx;">
								虚拟人数:{{ item.group_people.inventedPeople }}
							</view>
							<view class="">本团成员(人)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">{{item.group_people.sumCourse}}</view>
							<view class="">报名课程(个)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">¥{{item.group_people.sumMoney}}</view>
							<view class="">目前成交金额(元)</view>
						</view>
					</view>
				</view>
			</view>
			<view class="group-state-content" v-if="groupStatusIndex == 2" v-for="(item, index) in group_msg.fail" :key='index'>
				<view class="group-state-msg">
					<view class="group-state-msg-left">
						<view class="">
							<image :src="item.user_info != null ? item.user_info.avatar : '' " mode=""></image>
							<view class="">
								团长
							</view>
						</view>
						<text>{{item.user_info != null ?  item.user_info.nickname : ''}}</text>
					</view>
					<view class="group-state-msg-right">
						开团时间：<text>{{item.date_added | formatDates}}</text>
					</view>
				</view>
				<view class="group-state-details">
					<view class="group-state-details-top">
						<view class="group-state-title-details">
							拼团情况
						</view>
						<view class="" @click="checkMenber(item,'fail')">
							<view class="">
								查看成员
							</view>
							<image :src="imglink + 'home/arrow-right.png'" mode=""></image>
						</view>
					</view>
					<view class="group-state-details-bottom">
						<view class="course-statistics-details">
							<view class="" style="color: #FF391F;">{{item.group_people.count}}<text style="font-size: 28upx;color: #333333;">/{{order_detail.groupTotal}}</text></view>
							<view class="lack" style="width: 122upx;">
								虚拟人数:{{ item.group_people.inventedPeople }}
							</view>
							<view class="">本团成员(人)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">{{item.group_people.sumCourse}}</view>
							<view class="">报名课程(个)</view>
						</view>
						<view class="course-statistics-line"></view>
						<view class="course-statistics-details">
							<view class="">¥{{item.group_people.sumMoney}}</view>
							<view class="">目前成交金额(元)</view>
						</view>
					</view>
				</view>
				<view class="group-state-defeated">
					* 拼团失败，系统已经自动退款
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				imglink: this.$store.state.imgLink,
				groupStatus:['拼团中','拼团完成','拼团失败'],
				groupStatusIndex:0,
				store_id:'',
				activity_title: '',
				order_detail: {},
				act_msg:{},
				group_msg:{}
			}
		},
		onLoad(option) {
			// this.activity_title = option.activity_title
			let store_id = parseInt(option.store_id,10);
			if(!store_id>0){
				store_id = uni.getStorageSync('store_id')
			}else{
				uni.setStorageSync('store_id', store_id)
			}
			this.store_id = store_id
			this.$store.commit('updateStoreId',store_id)
			this.act_msg = uni.getStorageSync('actPerfor')
			console.log(this.act_msg)
		},
		
		onShow() {
			this.gainData()
		},
		filters:{
			formatDates(value) {
				let date = new Date(value * 1000);
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM;
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h;
				let mm = date.getMinutes();
				mm = mm < 10 ? ('0' + mm) : mm;
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s;
				return y + '-' + MM + '-' + d + '  ' + h + ':' + mm + ':' + s;
			}
		},
		methods:{
			excelClick(){
				uni.navigateTo({
					url:'../../shopPerformance/execlForm/execlForm?store_id=' + this.store_id
				})
			},
			stateClick(index){
				this.groupStatusIndex = index
			},
			checkMenber(item,flag){
				uni.setStorageSync('checkMember',item)
				uni.setStorageSync('groupMsh',this.order_detail)
				uni.navigateTo({
					url:'../groupMemberDetails/groupMemberDetails?store_id=' + this.store_id + '&group_status=' + flag
				})	
			},
			gainData(){
				let data = {
					token:this.$store.getters.getToken,
					// 测试数据传递1(acitivity_id为1有数据)
					activity_id: this.act_msg.activity_id
					// activity_id:uni.getStorageSync('actPerfor').activity_id
				}
				this.$api.gain_act_order_details(data).then(res => {
					if(res.status){
						this.order_detail = res
						this.group_msg = res.assemble
						console.log(">>>>>> order-detail >>>>>>")
						console.log(this.order_detail)
					}
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style>
	page{
		background: #F3F3F4;
	}
	.all-perfor{
		width: 100%;
		padding: 30upx;
		box-sizing: border-box;
		background: #FFFFFF;
	}
	.all-perfor-title{
		text-align: center;
		color: #666666;
		font-size: 40upx;
		margin-top: 10upx;
	}
	.all-perfor-tip{
		color: #333333;
		font-size: 34upx;
		margin-top: 40upx;
		font-weight: 800;
	}
	.all-perfor-money{
		padding: 30upx 0;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		border-top: 1upx solid #DEDEDE;
		margin-top: 30upx;
		border-bottom: 1upx solid #DEDEDE;
	}
	.all-perfor-money>view:first-child{
		color: #333333;
		font-size: 30upx;
	}
	.all-perfor-money>view:last-child{
		color: #FF391F;
		font-size: 34upx;
	}
	.all-perfor-money>view>text{
		font-size: 28upx;
	}
	.course-statistics{
		margin-top: 28upx;
	}
	.course-statistics-title{
		color: #333333;
		font-size: 30upx;
	}
	.course-statistics-content{
		display: flex;
		justify-content: space-around;
		margin-top: 40upx;
		text-align: center;		
	}
	.course-statistics-details>view:first-child{
		color: #333333;
		font-size: 36upx;
	}
	.course-statistics-details>view:last-child{
		color: #999999;
		font-size: 24upx;
	}
	.course-statistics-line{
		width: 2upx;
		height: 46upx;
		border-left: 2upx solid #DEDEDE;
		margin-top: 20upx;
	}
	.perfor-execl{
		width: 638upx;
		height: 88upx;
		line-height: 88upx;
		text-align: center;
		margin: 0 auto;
		margin-top: 52upx;
		color: #FFFFFF;
		font-size: 32upx;
		border-radius: 44upx;
		background: linear-gradient(to right,#FE9543,#FF664F);
		box-shadow: 0 8upx 16upx 0 rgba(166, 13, 0, 0.23);
	}
	.group-state{
		margin-top: 20upx;
	}
	.group-state-title{
		width: 100%;
		background: #FFFFFF;
		padding: 0 30upx;
		box-sizing: border-box;
	}
	.group-state-title>view{
		padding: 18upx 0;
		box-sizing: border-box;
		width: 100%;
		border-bottom: 1upx solid #DEDEDE;
	}
	.group-state-contain{
		width: 100%;
		height: 64upx;
		line-height: 64upx;
		display: flex;
		background: #F2F2F2;
		border-radius: 32upx;
	}
	.group-state-contain>view{
		width: 33%;
		text-align: center;
		color: #666666;
		font-size: 32upx;
		border-radius: 32upx;
	}
	.group-state-contain .group-state-active{
		background: linear-gradient(to right,#FE9543,#FF664F);
		color: #FFFFFF;
	}
	.group-state-content{
		width: 100%;
		padding: 20upx 30upx 30upx;
		box-sizing: border-box;
		background: #FFFFFF;
	}
	.group-state-msg{
		display: flex;
		justify-content: space-between;
	}
	.group-state-msg-left{
		display: flex;
	}
	.group-state-msg-left>text{
		display: inline-block;
		color: #333333;
		font-size: 28upx;
		margin-left: 20upx;
		line-height: 80upx;
	}
	.group-state-msg-left>view,.group-state-msg-left>view>image{
		width: 80upx;
		height: 80upx;
		border-radius: 50%;
	}
	.group-state-msg-left>view{
		position: relative;
	}
	.group-state-msg-left>view>view{
		width: 66upx;
		height: 28upx;
		text-align: center;
		color: #FFFFFF;
		line-height: 28upx;
		border-radius: 14upx 14upx 14upx 0;
		background: #FF8B46;
		font-size: 22upx;
		position: absolute;
		top: -10upx;
		right: -48upx;
	}
	.group-state-msg-right{
		color: #666666;
		font-size: 24upx;
		line-height: 80upx;
	}
	.group-state-msg-right>text{
		color: #333333;
	}
	.group-state-details{
		width: 100%;
		height: 204upx;
		background: #F4F5F9;
		margin-top: 30upx;
		padding:  0 20upx;
		box-sizing: border-box;
	}
	.group-state-details-top{
		display: flex;
		justify-content: space-between;
		padding: 20upx 0;
		box-sizing: border-box;
		border-bottom: 1upx solid #DEDEDE;
	}
	.group-state-title-details{
		color: #333333;
		font-size: 30upx;
		line-height: 50upx;
	}
	.group-state-details-top>view:last-child{
		display: flex;
	}
	.group-state-details-top>view:last-child>view{
		width: 120upx;
		height: 50upx;
		line-height: 50upx;
		text-align: center;
		color: #FFFFFF;
		border-radius: 4upx;
		background: linear-gradient(to right,#FE9543,#FF664F);
		box-shadow: 0 8upx 16upx 0 rgba(166, 13, 0, 0.23);
		font-size: 24upx;
		margin-right: 20upx;
	}
	.group-state-details-top>view>image{
		width: 12upx;
		height: 20upx;
		margin-top: 16upx;
	}
	.group-state-details-bottom{
		display: flex;
		justify-content: space-around;
		margin-top: 28upx;
		text-align: center;
	}
	.course-statistics-details{
		position: relative;
	}
	.lack{
		width: 78upx;
		height: 28upx;
		line-height: 28upx;
		text-align: center;
		color: #FFFFFF;
		border-radius: 14upx 14upx 14upx 0;
		background: #FF391F;
		font-size: 22upx;
		position: absolute;
		top: -14upx;left: 100upx;
	}
	.group-state-defeated{
		color: #FF391F;
		font-size: 24upx;
		margin-top: 10upx;
	}
</style>
